var $ = require('jquery');
var init = require('../util/init.js');
var util = require('../util/util.js');
var receiveDetail = require('../component/detail/receiveDetail.js');
var bigBottomButton = require('../component/common/bigBottomButton.js');
require('../../scss/receiveDetail.scss');
init.initNav(true, '收件详情');

var urlGet = util.urlGet();
$.get(
    util.getAjaxUrl('/detail'),
    {
        type: urlGet.type,
        id: urlGet.id
    },
    function (data) {
        receiveDetail.init($("#receiveDetail"), data.data);
        if (data.data.state == "6") {
            var latestInfo = (data.data.latestInfo.split(" "))[0];
            bigBottomButton.init($("#bottomButton"), 'http://d2.freep.cn/3tb_160505103418f52d564060.png', '实时位置');
            $("#bottomButton").show();
            $("#bottomButton").click(function () {
                util.changePage("./map?position=" + encodeURIComponent(latestInfo));
            });
        }
    }
);

